/**
 * 
 */
package com.websem.client.views;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.uibinder.client.UiTemplate;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Widget;
import com.websem.client.services.FilmService;
import com.websem.client.services.FilmServiceAsync;

/**
 * @author issam
 * 
 */
public class TemplateView extends Composite {

	private static TemplateViewUiBinder uiBinder = GWT
			.create(TemplateViewUiBinder.class);
	FilmServiceAsync service = (FilmServiceAsync) GWT.create(FilmService.class);

	@UiTemplate("TemplateView.ui.xml")
	interface TemplateViewUiBinder extends UiBinder<Widget, TemplateView> {
	}

	public TemplateView() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	@UiField
	Button button;
	
	public TemplateView(String firstName) {
		initWidget(uiBinder.createAndBindUi(this));

		// Can access @UiField after calling createAndBindUi
		button.setText(firstName);
	}

	@UiHandler("button")
	void onClick(ClickEvent e) {
		Window.alert("Hello This is a template!");
	}

	public void setText(String text) {
		button.setText(text);
	}

	/**
	 * Gets invoked when the default constructor is called and a string is
	 * provided in the ui.xml file.
	 */
	public String getText() {
		return button.getText();
	}

}
